<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<link rel="stylesheet" media="screen" href="css/docs.css"/>
<link rel="stylesheet" media="screen" href="lib/jqplot/jquery.jqplot.min.css"/>
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>

<script type="text/javascript" src="${ctx}/js/global_util.js"></script>

<h1 class="page-title">用款申请单 - 添加</h1>

<div class="container_12 clearfix leading">
    <h5>流水号：<strong id="financial_serial_number"> </strong></h5>

    <div class="side grid_12 leading">
        <form class="form has-validation" name="post_form" id="post_form">
            <div class="clear"></div>
            <div class="clearfix">
                <label for="form_companyFullName" class="form-label">收款单位全称 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="form_companyFullName" name="financialPaymentApplyForm.companyFullName" required="required" placeholder=""/>
                </div>
            </div>

            <div class="clear"></div>
            <div class="clearfix">
                <label for="form_companyBankName" class="form-label">收款单位银行 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="form_companyBankName" name="financialPaymentApplyForm.companyBankName"  required="required" placeholder=""/>
                </div>
            </div>

            <div class="clear"></div>
            <div class="clearfix">
                <label for="form_amount" class="form-label">用款金额数 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="form_amount" name="financialPaymentApplyForm.amount" required="required" placeholder=""/>
                </div>
            </div>

            <div class="clear"></div>
            <div class="clearfix">
                <label for="form_purpose" class="form-label">用款用途 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="form_purpose" name="financialPaymentApplyForm.purpose" required="required" placeholder=""/>
                </div>
            </div>

            <div class="clear"></div>
            <div class="clearfix">
                <label for="form_operator" class="form-label">经办人 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="form_operator" name="financialPaymentApplyForm.operator" required="required" placeholder=""/>
                </div>
            </div>

            <div class="clear"></div>
            <div class="clearfix">
                <label for="form_inAccount" class="form-label">汇入账号 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="form_inAccount" name="financialPaymentApplyForm.inAccount" required="required" placeholder=""/>
                </div>
            </div>

            <div class="clear"></div>
            <div class="clearfix">
                <label for="form_confirm" class="form-label">账务核实 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="form_confirm" name="financialPaymentApplyForm.confirm" required="required" placeholder=""/>
                </div>
            </div>

            <div class="clear"></div>
            <div class="clearfix">
                <label for="form_useWay" class="form-label">用款方式 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="form_useWay" name="financialPaymentApplyForm.useWay" required="required" placeholder=""/>
                </div>
            </div>

            <div class="clear"></div>
            <div class="clearfix">
                <label for="form_debt" class="form-label">账面结欠 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="form_debt" name="financialPaymentApplyForm.debt" required="required" placeholder=""/>
                </div>
            </div>

            <input type="hidden" name="financialPaymentApplyForm.serialNumber" id="form_serialNumber">
            <div class="form-action clearfix">
                <button class="button" type="button" onclick="checkForm()">添加</button>
                <button class="button" type="reset">重置</button>
                <a class="button" href="#${userType==1?"sign" : "public"}/financial-payment-apply-form.xhtml"> <span style="background:url(${ctx}/images/img/arrow_undo.png)" class="icon">&nbsp;</span>返回</a>
            </div>
        </form>
    </div>
</div>

<div class="clear"></div>

<script type="text/javascript" src="js/Tree.js"></script>
<script type="text/javascript">
    $(function(){
        var serial = createSerialNumber();
        $("#financial_serial_number").html(serial);
        $("#form_serialNumber").val(serial);
    });

    function checkForm(){
        var form_companyFullName = $("#form_companyFullName").val();
        if(checkNull(form_companyFullName)){
            alert("请填写收款单位全称");
            return;
        }
        var form_companyBankName = $("#form_companyBankName").val();
        if(checkNull(form_companyBankName)){
            alert("请填写收款单位银行");
            return;
        }
        var form_amount = $("#form_amount").val();
        if(checkNull(form_amount) || isNaN(form_amount)){
            alert("请正确填写用款金额数");
            return;
        }
        var form_purpose = $("#form_purpose").val();
        if(checkNull(form_purpose)){
            alert("请填写用款用途");
            return;
        }
        var form_operator = $("#form_operator").val();
        if(checkNull(form_operator)){
            alert("请填写经办人");
            return;
        }
        var form_inAccount = $("#form_inAccount").val();
        if(checkNull(form_inAccount)){
            alert("请填写汇入账号");
            return;
        }
        var form_confirm = $("#form_confirm").val();
        if(checkNull(form_confirm)){
            alert("请填写账务核实");
            return;
        }
        var form_useWay = $("#form_useWay").val();
        if(checkNull(form_useWay)){
            alert("请填写用款方式");
            return;
        }
        var form_debt = $("#form_debt").val();
        if(checkNull(form_debt)){
            alert("请填写账面结欠");
            return;
        }

        var data  = $("#post_form").serialize();
        var url = "${ctx}/${userType==1?"sign" : "public"}/financial-payment-apply-form-save.xhtml";
        $.ajax(url, {
            type: "POST",
            data: data,
            dataType:"html",
            cache:false,
            success:function(a) {
                return pageDownloaded(a, url)
            },
            complete:function() {}
        });
    }
</script>